import { setToken, getToken, removeToken } from '@/utils/storage'

export default {
  // 命名空间开启
  namespaced: true,
  state () {
    return {
      token: getToken()
    }
  },
  getters: {},
  mutations: {
    // 准备一个修改token的方法
    updateToken (state, payload) {
      state.token = payload

      setToken(payload)
    },

    // 登出方法
    logout (state) {
      state.token = ''
      removeToken()
    }
  },
  actions: {}
}
